#########consumption
library(readxl)
dat01<-read_excel("C:\\Users\\LiJie\\Desktop\\10sector10region.xls",sheet = "consumption")
head(dat01)


table(dat01$Sector)
dat01$Sector<-factor(dat01$Sector,levels = rev(c("Agriculture、Forestry and fishing","Mining","Light industrial manufacturing","High-end heavy industrial manufacturing","Petroleum industry","Electricity, gas, steam，water","Construction","Transportation and storage","Basic services","High-tech services")))

library(ggplot2)
ggplot(data = dat01,aes(x=Region,y=Value,fill=Sector))+
  geom_bar(stat = "identity",position = "stack")+
  coord_flip()+
  #scale_fill_discrete(limits=c("Agriculture、Forestry and fishing","Mining","Light industrial manufacturing","High-end heavy industrial manufacturing","Petroleum industry","Electricity, gas, steam，water","Construction","Transportation and storage","Basic services","High-tech services"))+
  # scale_fill_manual(values = c("Agriculture、Forestry and fishing"="#a27e7e","Mining"="#a6a6a8","Light industrial manufacturing"="#ead0d1","High-end heavy industrial manufacturing"="#faead3",
  #                             "Petroleum industry"="#c7b8a1","Electricity, gas, steam，water"="#c9c0d3",
  #                             "Construction"="#eee5f8","Transportation and storage"="#F2CA97","Basic services"="#EDD8A8","High-tech services"="#D4CBAC"),limits=c("Agriculture、Forestry and fishing","Mining","Light industrial manufacturing","High-end heavy industrial manufacturing","Petroleum industry","Electricity, gas, steam，water","Construction","Transportation and storage","Basic services","High-tech services"))+
  scale_fill_discrete(limits=c("Agriculture、Forestry and fishing","Mining","Light industrial manufacturing","High-end heavy industrial manufacturing","Petroleum industry","Electricity, gas, steam，water","Construction","Transportation and storage","Basic services","High-tech services"))+
  scale_fill_manual(values = c("Agriculture、Forestry and fishing"="#cc4400","Mining"="#d66915","Light industrial manufacturing"="#e08e29","High-end heavy industrial manufacturing"="#f0c761",
                              "Petroleum industry"="#f9fcb5","Electricity, gas, steam，water"="#c2fcff",
                             "Construction"="#7cc6de","Transportation and storage"="#3890bc","Basic services"="#1c489a","High-tech services"="#000077"),limits=c("Agriculture、Forestry and fishing","Mining","Light industrial manufacturing","High-end heavy industrial manufacturing","Petroleum industry","Electricity, gas, steam，water","Construction","Transportation and storage","Basic services","High-tech services"))+
  
  theme(legend.text=element_text( size =10,family="serif"),axis.text.y = element_text( size =10,family="serif",color="black"),axis.text.x = element_text( size = 10,family="serif",color="black"))



########embodied emissions
library(readxl)
dat01<-read_excel("C:\\Users\\LiJie\\Desktop\\russia-r.xls",sheet = "15 embodied imp sector")
head(dat01)


table(dat01$Sector)
dat01$Sector<-factor(dat01$Sector,levels = rev(c("Agriculture、Forestry and fishing","Mining","Light industrial manufacturing","High-end heavy industrial manufacturing","Petroleum industry","Electricity, gas, steam，water","Construction","Transportation and storage","Basic services","High-tech services","Intermediate Goods")))

library(ggplot2)
ggplot(data = dat01,aes(x=Region,y=Value,fill=Sector))+
  geom_bar(stat = "identity",position = "stack")+
  coord_flip()+
  scale_fill_discrete(limits=c("Agriculture、Forestry and fishing","Mining","Light industrial manufacturing","High-end heavy industrial manufacturing","Petroleum industry","Electricity, gas, steam，water","Construction","Transportation and storage","Basic services","High-tech services","Intermediate Goods"))+
  scale_fill_manual(values = c("Agriculture、Forestry and fishing"="#54478c","Mining"="#2c699a","Light industrial manufacturing"="#048ba8","High-end heavy industrial manufacturing"="#0db39e",
                               "Petroleum industry"="#16db93","Electricity, gas, steam，water"="#83e377",
                               "Construction"="#b9e769","Transportation and storage"="#efea5a","Basic services"="#f1c453","High-tech services"="#f29e4c","Intermediate Goods"="#CDCDCD"),limits=c("Agriculture、Forestry and fishing","Mining","Light industrial manufacturing","High-end heavy industrial manufacturing","Petroleum industry","Electricity, gas, steam，water","Construction","Transportation and storage","Basic services","High-tech services","Intermediate Goods"))





########Pie chart
library(readxl)
data<-read_excel("C:\\Users\\LiJie\\Desktop\\t.xls",sheet = "74")
head(data)
data$Group <- factor(data$Group, levels=data$Group) 
library(ggplot2)
mylabel<-paste(data[,2],"%")  
mylabel<-rev(mylabel) 
percent<-rev(data$Percentage) 

p<-ggplot(data,aes(x="",y=Percentage,fill=Group)) +
  geom_bar(stat = "identity") + 
  coord_polar(theta = "y") +
  theme(legend.text=element_text( size =10,family="serif"),
        axis.text.x = element_blank(),
        axis.ticks = element_blank(),
        panel.grid = element_blank()) +
  #geom_text(aes(y= cumsum(percent)-percent/2, x= 1),label=mylabel)+
  scale_fill_manual(values = c("Final consumption expenditure by households"='#FDFDD4', "Individual final consumption expenditure by Public Administration"='#DBF0B3', "Collective final consumption expenditure by Public Administration"='#91D5BA', "Final consumption expenditure by non-profit institution serving households (NPISH)"='#3DB3C4', 
                               "Gross fixed capital formation"='#1C80B9', "Change in inventories"='#224299', "Acquisition less disposals of valuables"='#091F5E'))

p

